<?PHP
/*
*	File: 		includes/forum/category.class.php
*	Use:		Category Class
*	Functions:	
*
*	Misc:		Class: users
*				Description: handles querys about users (logins, profile changes, etc)
*
*	Coder:		Andrew Thorne, UK
*	Copyright:	No part of this code may be used for any purpose other 
*				than the original intended purpose without prior written 
*				permission of Andrew Thorne. 
*				Use for any other purpose is expressly prohibited by law, 
*				and may result in civil and criminal penalties.
*
*	Contact:	omgrofl@hotmail.co.uk
*
*/
	

class category {

	
	/* 
	*
	* Function: getCategory
	*
	*/
	public function getCategory($db, $cat_id){
		
		$prefix = $db->getPrefix();	

		if(is_numeric($_SESSION['groupid']) && ($_SESSION['groupid']=="" || !isset($_SESSION['groupid']))){
			$groupId=0;	
		} else {
			$groupId=$db->prep($_SESSION['groupid']);
		}
		if(is_numeric($cat_id)){
			return $db->query("SELECT * FROM ".$prefix."forum_category a INNER JOIN ".$prefix."forum_perms_cat b ON a.cat_id=b.cat_id WHERE a.cat_active=1 AND b.user_group_id=".$groupId." AND b.view=1 a.cat_id=".$db->prep($cat_id)."");
		} else {
			return false;	
		}
		
	}
	
	/* 
	*
	* Function: getAllCategorys
	*
	*/
	public function getAllCategorys($db){
		
		$prefix = $db->getPrefix();	
		
		if(is_numeric($_SESSION['groupid']) && ($_SESSION['groupid']=="" || !isset($_SESSION['groupid']))){
			$groupId=0;	
		} else {
			$groupId=$db->prep($_SESSION['groupid']);
		}
		return $db->query("SELECT * FROM ".$prefix."forum_category a INNER JOIN ".$prefix."forum_perms_cat b ON a.cat_id=b.cat_id WHERE a.cat_active=1 AND b.user_group_id=".$groupId." AND b.view=1 ORDER BY a.cat_order ASC");		
		
	}
}
?>